<?php
defined('BASEPATH') OR exit('No direct script access allowed');


use QCloud_WeApp_SDK\Mysql\Mysql as DB;


class AddressAdd extends CI_Controller
{
    public function index()
    {
        $userid = $_GET['userid'];
        $name = $_GET['name'];
        $tel = $_GET['tel'];
        $province = $_GET['province'];
        $city = $_GET['city'];
        $area = $_GET['area'];
        $address = $_GET['address'];
        $rows = null;
        if ($userid) {
            $rows = DB::insert('cc_address', ['userid' => $userid, 'name' => $name,
                'tel' => $tel, 'province' => $province,
                'city' => $city, 'area' => $area, 'address' => $address]);
        }

        if (!empty($rows)) {
            $this->json([
                'code' => 0,
                'data' => $rows
            ]);
        } else {
            $this->json([
                'code' => -1,
                'error' => $rows['error']
            ]);
        }
    }
}
